<script >
export default{
    data(){
        return{
            name:'',
            newId:3,
            list:[
                {id:1,name:'抑郁'},
                {id:2,name:'高兴'},
                {id:3,name:'悲伤'}
            ]
        }
    },methods:{
        add(){
            this.list.unshift({id:++this.newId,name:this.name})
            this.name=""
            console.log('321321');
        }
    }
}
</script>

<template>  
<div>
    <input type="text" name="" id="" v-model="name">
    <input type="button" value="添加" @click='add'>
</div>
<ul>
    <span>无key的选框按钮</span>
    <li v-for="(item,index) in list">
    <input type="radio" name="1" id="">{{ item.name }}</li>

</ul>
<ul>
    <span>有key的选框按钮</span>
    <li v-for="(item,index) in list" :key="item.id">
    <input type="radio" name="1" id="">{{ item.name }}</li>
</ul>
</template>

<style scoped>

</style>
